#include <stdio.h>

inline unsigned  mypow(unsigned int num , int c ){
	int i , j=1;
	if( c< 0 ){
		return 1;
	}else if(c == 0){
		return 1;
	}
	for(i=0;i<c;i++ ){
		j *= num;
	}
	
	return j;
}

int NumOfMbitsConsecutiveOneInNbits( int totle , int cont ){
	int move;
	move = totle - cont;

	int i,d;
	int count=0;
	if( totle < cont ){
		return 0;
	}

	for(i=move;i>=0;i--){
		d = NumOfMbitsConsecutiveOneInNbits( move-i-1, cont );
		count += mypow(2,i)*(mypow(2,move-i-1)-d);

	}
	return count;
}

int NumOfOnlyMBitsConsecutiveOneInNBits( unsigned int N , int M){
	int i;
	int count = 0;
	for(i=0 ; i <=(N-M) ; i++ ){
		count += (mypow(2,N-M-i-1)-NumOfMbitsConsecutiveOneInNbits(N-M-i-1,M))*(mypow(2,i-1) - NumOfMbitsConsecutiveOneInNbits(i-1,M));
	}
	return count;	
}
int NumOfRoundOnlyMBitsConsecutiveOneInNbits( unsigned int N , int M ){
	int i;
	int count = 0;
	count  = N* (mypow(2,N-M-2)-NumOfMbitsConsecutiveOneInNbits(N-M-2,M));

	return count;
}
int main( int argc , char ** argv){
	int n=5,m=4 , b;
	if( argc > 1 ){
		n = atoi(argv[1]);
	}
	if( argc > 2 ){
		m = atoi(argv[2]);
	}
	printf("%u\n",NumOfOnlyMBitsConsecutiveOneInNBits( n ,m));
	printf("18:%u\n",NumOfRoundOnlyMBitsConsecutiveOneInNbits( 18 , 4 ));
	return 0;
}
